package com.study.lihan;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;
/*
-XX:+UseBiasedLocking
-XX:BiasedLockingStartupDelay=0
* */
@Slf4j(topic="c.TestBiased")
public class TestBiased {

    public static void main(String[] args) {

        Dog dog = new Dog();
        new Thread (() ->{
            log.info(ClassLayout.parseInstance(dog).toPrintable()+ "    a");//5
            synchronized (dog) {
                log.info(ClassLayout.parseInstance(dog ).toPrintable()+ " b");//5
            }
            log.info(ClassLayout.parseInstance(dog ).toPrintable()+ "    c");//5
            synchronized (TestBiased.class) {
                TestBiased.class.notify();
                log.info("线程1");
            }

        },"t1").start();

        new Thread (() ->{
            synchronized (TestBiased.class) {
                try {
                    log.info("线程2");
                    TestBiased.class.wait();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            log.info(ClassLayout.parseInstance(dog).toPrintable()+ "    a");//5
            synchronized (dog) {
                log.info(ClassLayout.parseInstance(dog ).toPrintable()+ " b");//5
            }
            log.info(ClassLayout.parseInstance(dog ).toPrintable()+ "    c");//5
            synchronized (TestBiased.class) {
                TestBiased.class.notify();
            }


        },"t2").start();


    }

}


class Dog{

}